<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Bai 2.15</title>
</head>

<body>
<?php
	if(isset($_POST['duong']))
	{
		$nam_dl=$_POST['duong'];
		if(is_numeric($nam_dl)){
			$nam_tru=$nam_dl-3;
			$nam=$nam_tru%10;
			//Tính can
			switch($nam){
				case 1:$can="Giáp";break;
				case 2:$can="Ất";break;
				case 3:$can="Bính";break;
				case 4:$can="Đinh";break;
				case 5:$can="Mậu";break;
				case 6:$can="Kỷ";break;
				case 7:$can="Canh";break;
				case 8:$can="Tân";break;
				case 9:$can="Nhâm";break;
				case 0:$can="Quý";break;
			}
			$nam=$nam_tru%12;
			//Tính chi
			switch($nam){
				case 1:$chi="Tý";break;
				case 2:$chi="Sửu";break;
				case 3:$chi="Dần";break;
				case 4:$chi="Mão";break;
				case 5:$chi="Thìn";break;
				case 6:$chi="Tỵ";break;
				case 7:$chi="Ngọ";break;
				case 8:$chi="Mùi";break;
				case 9:$chi="Thân";break;
				case 10:$chi="Dậu";break;
				case 11:$chi="Tuất";break;
				case 0:$chi="Hợi";break;
			}
			$am=$can.' '.$chi;
		}
	}
?>
<form id="form1" name="form1" method="post" action="Bai2_15.php">
  <table width="500" border="0" align="center" cellpadding="0" cellspacing="0">
    <tr bgcolor="#FF66CC">
      <td colspan="3" style="text-align: center; font-weight: bold; font-style: italic; color: #FFF; font-size: 24px;">TÍNH NĂM ÂM LỊCH</td>
    </tr>
    <tr bgcolor="#FF99CC">
      <td nowrap="nowrap" style="text-align: center">Năm dương lịch</td>
      <td nowrap="nowrap" style="text-align: center">&nbsp;</td>
      <td nowrap="nowrap" style="text-align: center">Năm âm lịch</td>
    </tr>
    <tr bgcolor="#FFCCFF">
      <td nowrap="nowrap" style="text-align: center"><input name="duong" type="text" id="duong" value="<?php echo $_POST['duong'];?>" /></td>
      <td nowrap="nowrap" style="text-align: center"><input type="submit" name="button" id="button" value="=&gt;" /></td>
      <td nowrap="nowrap" style="text-align: center"><input style="background-color:#FFC; text-align:center;color:#F36; font-weight:bold" name="am" type="text" id="am" value="<?php echo $am;?>" readonly="readonly" /></td>
    </tr>
  </table>
</form>
</body>
</html>